package com.jinken.rocketmq;


import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MessageProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;


    @Value("${rocketmq.consumer.topic}")
    private String topic;

    public SendResult sendMessage(String message){
        SendResult sendResult = rocketMQTemplate.syncSend(topic, message);
        return sendResult;
    }
}
